import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [{
  path: '/',
  redirect: '/home' // 重定向
},
{
  path: "/home",
  name: "home",
  component: resolve => {
    require(['../views/main/index.vue'], resolve)
  },
},
{
  name: 'toplist',
  path: '/toplist',
  component: resolve => {
    require(['../views/toplist/index.vue'], resolve)
  },
},
{
  name: 'songlist',
  path: '/songlist',
  component: resolve => {
    require(['../views/songlist/index.vue'], resolve)
  },
},
{
  name: 'mv',
  path: '/mv',
  component: resolve => {
    require(['../views/mv/index.vue'], resolve)
  },
},
{
  name: 'mylist',
  path: '/mylist',
  component: resolve => {
    require(['../views/mylist/index.vue'], resolve)
  },
},
{
  name: 'song',
  path: '/song',
  component: resolve => {
    require(['../views/song/index.vue'], resolve)
  },
},
{
  name: 'search',
  path: '/search',
  component: resolve => {
    require(['../views/search/index.vue'], resolve)
  },
},
{
  name: 'songdetails',
  path: '/songdetails',
  component: resolve => {
    require(['../views/Songdetails/index.vue'], resolve)
  },
},
{
  name: 'albumdetails',
  path: '/albumdetails',
  component: resolve => {
    require(['../views/album/index.vue'], resolve)
  },
},

]

const router = new VueRouter({
  mode: 'history', // 路由历史模式
  routes
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router